import axios from 'axios'

export default {
	/**
	 * 获取角色信息
	 * @returns {AxiosPromise<any>}
	 */
	fetchRoles () {
		return axios.get('/api/system/role');
	},
	/**
	 * 创建角色
	 * @param params
	 * @returns {AxiosPromise<any>}
	 */
	store (params) {
		return axios.post('/api/system/role', params);
	},
	/**
	 * 更新角色信息
	 * @param code
	 * @param params
	 * @returns {AxiosPromise<any>}
	 */
	update (code, params) {
		return axios.patch(`/api/system/role/${code}`, params);
	},
	/**
	 * 删除角色信息
	 * @param code
	 * @returns {AxiosPromise}
	 */
	delete (code) {
		return axios.delete(`/api/system/role/${code}`);
	},
	/**
	 * 获取角色的权限信息
	 * @param code
	 * @returns {AxiosPromise<any>}
	 */
	fetchPermissionRelationshipByCode (code) {
		return axios.get(`/api/system/role/${code}/permission`);
	},
	syncRelationship (code, params) {
		return axios.patch(`/api/system/role/${code}/permission`, params);
	}
}
